package com.woniu.cq.malluser.service.impl;

import com.woniu.cq.malluser.domain.User;
import com.woniu.cq.malluser.mapper.UserMapper;
import com.woniu.cq.malluser.params.CodeParam;
import com.woniu.cq.malluser.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author daniel
 * @since 2020-09-19
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public void register(CodeParam codeParam) {
        String mobile = codeParam.getMobile();
        String code = stringRedisTemplate.opsForValue().get("mobile:" + mobile);
        String code1 = codeParam.getCode();
        String newCode = "code:"+code1;
        System.out.println(code1);
        System.out.println(code);
        if (code.equals(newCode)){
            System.out.println("--------------------------");
            User user = new User();
            user.setAge(18);
            user.setPhone(mobile);
            user.setUsername("张三");
            save(user);
        }
    }
}
